package homework07;

import java.io.File;
import java.util.HashMap;

public class homework002 {
	public static void main(String[] args) {
		File file=new File("D:\\");
		HashMap<String,Integer> hm=new HashMap<>();
		getCount(hm,file);
		System.out.println(hm);
	}
	private static void getCount(HashMap<String,Integer> hm,File file){
		File[] files=file.listFiles();
		if (files!=null){
			for (File file1 : files){
				if (file1.isFile()){
					String file1Name=file1.getName();
					String[] file1NameArr=file1Name.split("\\.");
					if (file1NameArr.length==2){
						String s=file1NameArr[1];
						if(hm.containsKey(s)){
							Integer count=hm.get(s);
							count++;
							hm.put(s, count);
						}else{
							hm.put(s, 1);
						}
					}
				}else{
					getCount(hm,file1);
				}
			}
		}
	}
}
